import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv(r'911.csv')
temp_list = df['title'].str.split(":").tolist()
cate_list = list(i[0]for i in temp_list)
df['cate'] = pd.DataFrame(np.array(cate_list).reshape(df.shape[0], 1))
df['timeStamp'] = pd.to_datetime(df['timeStamp'])
df.set_index('timeStamp', inplace=True)
result_df = df.groupby('cate')
plt.figure(figsize=(20, 12))
for name, data in result_df:
    count_by_month = data.resample('ME').count()['title']
    x = [i.strftime('%Y-%m-%d') for i in count_by_month.index]
    y = count_by_month.values
    plt.plot(range(len(x)), y, label=name)
    plt.xticks(range(len(x)), x, rotation=45)
plt.legend(loc='best')
plt.show()